<template>
	<view>
		<uni-nav-bar :statusBar="true" dark title="添加分组" fixed left-icon="left" @clickLeft="clickLeft">
			<block slot="right">
				<view class="city">
					<view @click="onCreated">
						添加
					</view>
				</view>
			</block>
		</uni-nav-bar>
		<view class="content">
			<uni-forms class="form" ref="baseForm" :modelValue="baseFormData" :rules="customRules">
				<uni-forms-item labelWidth="180rpx" label="分组名称" required name="teamName">
					<uni-easyinput v-model="baseFormData.teamName" placeholder="请输球队名称" />
				</uni-forms-item>
			</uni-forms>
		</view>
	</view>
</template>

<script>
	import {
		createTeamGrouping
	} from '@/api/basketballTeam/index.js'
	export default {
		data() {
			return {
				baseFormData: {
					teamName: ''
				},
				customRules: {
					teamName: {
						rules: [{
							required: true,
							errorMessage: '请输分组名称'
						}]
					},
				}
			}
		},
		methods: {
			clickLeft() {
				uni.navigateBack()
			},
			onCreated() {
				createTeamGrouping({name: this.baseFormData.teamName}).then(res => {
					this.$modal.msg(res.msg)
					setTimeout(() => {
						uni.navigateBack()
					}, 600)
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.content {
		padding: 40rpx 20rpx;

		.logo {
			display: flex;
			align-items: center;
			padding-bottom: 40rpx;
		}
	}
</style>